	
	/**
	 *【公共】加载页面时计算div id 为content页面的高度 add by JYX
	 */
	onload = function(){
		var t = document.getElementById("top");
		var c = document.getElementById("content");
		var f = document.getElementById("foot");
		if(t != undefined && c != undefined){
			var height = window.screen.availHeight - (window.screenTop + (window.screen.height - window.screen.availHeight));
			var top = t.offsetHeight;
			var foot = 0;
			if(f != undefined){
				foot = f.offsetHeight;
			}
			var content = height - top - foot;	//得到中间datagrid的高度（全部撑开网页的高度）
			c.style.height = content;
		}
	}


	/**
	 * 上传图片验证
	 * add by jyx
	 */
	var fileSize = 0; //檔案大小
    var SizeLimit = 1024*1024;  //上傳上限，單位:byte
    var fileName;	//上传文件名
    function checkPic(upload, flag) {
		if(flag == 0){
			return checkFile(upload);
    	}else if(flag == 5){
    		var rs = 0;
    		for(var i=0; i<flag; i++){
    			rs = rs + checkFile(upload + "[" + i + "]");
    		}
    		return rs;
    	}
    }
    function checkFile(upload) {
    	//debugger;
        var f = document.getElementById(upload);
        if(f == null || f.value == ''){
        	return 0;
        }else{
        	fileName = f.value;
        	if(!/.(gif|jpg|jpeg|png)$/.test(f.value.toLowerCase())){
    	        return -1;
        	}else{
        		//FOR IE
	            if ($.browser.msie) {
	                var img = new Image();
	                img.onload = checkSize;
	                img.src = f.value;
	            }
	            //FOR Firefox,Chrome
	            else {
	                fileSize = f.files.item(0).size;
	                return checkSize();
	            }
        	}
        }
        
    }
    //檢查檔案大小
    function checkSize() {
        //FOR IE FIX
        if ($.browser.msie) {
            fileSize = this.fileSize;
        }
        if (fileSize > SizeLimit) {
            return 1;
        }else{
        	return 0;
        }
    }

    function Message(msg) {
    	$.dialog.alert(msg, function(){
		});
    } 
    
    
	/**
	 * 价格验证方法之一
	 */
	var record = {
		num : ""
	}
	var checkDecimal = function(n) {
		var decimalReg = /^\d{0,8}\.{0,1}(\d{1,2})?$/;//var decimalReg=/^[-\+]?\d{0,8}\.{0,1}(\d{1,2})?$/; 
		if (n.value != "" && decimalReg.test(n.value)) {
			record.num = n.value;
			//$("#msg").html("<img src='${root}/image/right.png'><font id='basic' size='3' color='green'>通过信息验证！！</font>");
		} else {
			if (n.value != "") {
				n.value = record.num;
			}
		}
	}
	
	/**
	 * add by jiangyingxu
	 * 使用js截取前len字节的字符串，
	 * @param str 要截取的字符串
	 * @param len要截取的长度，根据字节计算
	 * @param suffix截取前len个后，其余的字符的替换字符一般用“…”
	 * @returns
	 */
	function cutString(str,len,suffix){  
	    if(!str) return "";  
	    if(len<= 0) return "";  
	    if(!suffix) suffix = "";  
	    var templen=0;  
	    for(var i=0;i<str.length;i++){  
	        if(str.charCodeAt(i)>255){  
	            templen+=2;  
	        }else{  
	            templen++; 
	        }  
	        if(templen == len){  
	            return str.substring(0,i+1)+suffix;  
	        }else if(templen >len){  
	            return str.substring(0,i)+suffix;  
	        }  
	    }  
        return str;  
	}
	
	/**
	 * 去除左右空格
	 * @returns
	 */
	String.prototype.trim=function() {
	    return this.replace(/(^\s*)|(\s*$)/g,'');
	}
	
	
	/**
	 * 调用easyui 的 排序方法
	 */
	function sortByColumn(sort,order){
		var form = document.forms[0];
		form.sortName.value = sort;
		if("" != form.sortOrder.value){
			if(form.sortOrder.value == "asc"){
				order = "desc";
			}else{
				order = "asc";
			}
		}	
		form.sortOrder.value = order;
		form.submit();
	}